const rp = require('request-promise-native')

async function fetchMovie(item) {
    const url = `http://api.douban.com/v2/movie/${item.doubanId}`
    console.log(url)
    let res = await rp(url)
    
    return res
}
;(async () => {
    let movies = [
        { doubanId: 25940531,
            title: '企鹅小守护',
            rate: 6.8,
            poster: 'https://img3.doubanio.com/view/photo/l_ratio_poster/public/p2269588796.jpg' },
        { doubanId: 26577728,
        title: '禁忌之恋',
        rate: 6.2,
        poster: 'https://img3.doubanio.com/view/photo/l_ratio_poster/public/p2270201875.jpg' }
    ]

    movies.map(async (movie) => {
        let movieData = await fetchMovie(movie)
        console.log(movieData)
        try {
            movieData = JSON.parse(movieData)
            console.log(movieData.tags)
            console.log(movieData.summary)
        } catch(err) {
            console.log(err)
        }
    })
})()